<template>
  <el-card>
    <div class="text-center">
      <div class="draw">
        <div class="top-left">
          <div class="idc" :class="{'is-active':['cs','zt','ty'].includes(from)}" @click="from='zt'">
            <template v-if="from==='zt'">
              <div class="pulse1"></div>
              <div class="pulse2"></div>
            </template>
            <el-popover placement="top" popper-class="my-popover" width="200" trigger="hover" :visible-arrow="false">
              <div class="info" @click="$router.push({name:'scheduler-resource',query:{provider:'长沙超算中心'}})">
                <div class="info-row">
                  <span>区域</span>
                  湖南省长沙市
                </div>
                <div class="info-row">
                  <span>集群名称</span>
                  长沙超算中心
                </div>
                <div class="info-row">
                  <span>CPU</span>
                  200核
                </div>
                <div class="info-row">
                  <span>GPU</span>
                  120核
                </div>
                <div class="info-row">
                  <span>内存</span>
                  8,960GiB
                </div>
                <div class="info-row">
                  <span>存储</span>
                  1,720TB
                </div>
                <div class="info-row">
                  <span>指令集</span>
                  X86/arm
                </div>
                <div class="info-row">
                  <span>运行任务</span>
                  {{random(10,99)}}个
                </div>
              </div>
              <div slot="reference" class="text cs">
                <div class="name">长沙超算中心</div>
                <div class="desc">超算算力HPC高性能计算</div>
              </div>

            </el-popover>

          </div>
          <div class="idc" :class="{'is-active':['xt','cs'].includes(from)}" @click="from='xt'">
            <template v-if="from==='xt'">
              <div class="pulse1"></div>
              <div class="pulse2"></div>
            </template>
            <el-popover placement="top" popper-class="my-popover" width="200" trigger="hover" :visible-arrow="false">
              <div class="info" @click="$router.push({name:'scheduler-resource',query:{provider:'深证光明数据中心'}})">
                <div class="info-row">
                  <span>区域</span>
                  湖南省湘潭市
                </div>
                <div class="info-row">
                  <span>集群名称</span>
                  深证光明数据中心
                </div>
                <div class="info-row">
                  <span>CPU</span>
                  200核
                </div>
                <div class="info-row">
                  <span>GPU</span>
                  120核
                </div>
                <div class="info-row">
                  <span>内存</span>
                  3,584GiB
                </div>
                <div class="info-row">
                  <span>存储</span>
                  560TB
                </div>
                <div class="info-row">
                  <span>指令集</span>
                  X86/arm
                </div>
                <div class="info-row">
                  <span>运行任务</span>
                  {{random(10,99)}}个
                </div>
              </div>
              <div slot="reference" class="text xt">
                <div class="name">深证光明数据中心</div>
                <div class="desc">通用算力</div>
              </div>
            </el-popover>
          </div>
        </div>
        <div class="top-right">
          <div class="idc " :class="{'is-active':['ty','cs','zt'].includes(from)}" @click="from='ty'">
            <template v-if="from==='ty'">
              <div class="pulse1"></div>
              <div class="pulse2"></div>
            </template>
            <el-popover placement="top" popper-class="my-popover" width="200" trigger="hover" :visible-arrow="false">
              <div class="info" @click="$router.push({name:'scheduler-resource',query:{provider:'长沙大数据中心'}})">
                <div class="info-row">
                  <span>区域</span>
                  湖南省长沙市
                </div>
                <div class="info-row">
                  <span>集群名称</span>
                  长沙大数据中心
                </div>
                <div class="info-row">
                  <span>CPU</span>
                  200核
                </div>
                <div class="info-row">
                  <span>GPU</span>
                  120核
                </div>
                <div class="info-row">
                  <span>内存</span>
                  1,100GiB
                </div>
                <div class="info-row">
                  <span>存储</span>
                  1,750TB
                </div>
                <div class="info-row">
                  <span>指令集</span>
                  X86/arm/risc-v
                </div>
                <div class="info-row">
                  <span>运行任务</span>
                  {{random(10,99)}}个
                </div>
              </div>
              <div slot="reference" class="text ty">
                <div class="name">长沙大数据中心</div>
                <div class="desc">智算算力</div>
              </div>
            </el-popover>
          </div>
        </div>
        <div class="center-center">
          <div class="idc" :class="{'is-active':['ty','cs','zt','xt'].includes(from)}" @click="from='cs'">
            <el-popover placement="top" popper-class="my-popover" width="200" trigger="hover" :visible-arrow="false">
              <div class="info" @click="$router.push({name:'scheduler-resource',query:{provider:'证通云谷数据中心'}})">
                <div class="info-row">
                  <span>区域</span>
                  湖南省长沙市
                </div>
                <div class="info-row">
                  <span>集群名称</span>
                  证通云谷数据中心
                </div>
                <div class="info-row">
                  <span>CPU</span>
                  200核
                </div>
                <div class="info-row">
                  <span>GPU</span>
                  120核
                </div>
                <div class="info-row">
                  <span>内存</span>
                  21,504GiB
                </div>
                <div class="info-row">
                  <span>存储</span>
                  4,200TB
                </div>
                <div class="info-row">
                  <span>指令集</span>
                  X86/arm/risc-v/mips
                </div>
                <div class="info-row">
                  <span>运行任务</span>
                  {{random(10,99)}}个
                </div>
              </div>
              <div slot="reference" class="text zt">
                <div class="name">证通云谷数据中心</div>
                <div class="desc">通用算力</div>
              </div>
            </el-popover>
            <!-- <el-popover placement="top" popper-class="my-popover" width="200" trigger="click" :visible-arrow="false">
              <div class="info">
                <div class="info-row">
                  <span>区域</span>
                  湖南省长沙市
                </div>
                <div class="info-row">
                  <span>集群名称</span>
                  长沙超算中心
                </div>
                <div class="info-row">
                  <span>CPU</span>
                  2,000核
                </div>
                <div class="info-row">
                  <span>GPU</span>
                  2,000核
                </div>
                <div class="info-row">
                  <span>内存</span>
                  2,000GiB
                </div>
                <div class="info-row">
                  <span>存储</span>
                  2,000TB
                </div>
                <div class="info-row">
                  <span>指令集</span>
                  X86/ARM/RISC-V/MIPS
                </div>
                <div class="info-row">
                  <span>运行任务</span>
                  53个
                </div>
              </div>
              <i slot="reference" class="el-icon-warning tips"></i>
            </el-popover> -->
            <template v-if="from==='cs'">
              <div class="pulse1"></div>
              <div class="pulse2"></div>
            </template>
          </div>
        </div>
        <div class="svg svg-cs-zt ">
          <svg width="301" height="161" viewBox="0 0 301 161" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path opacity="0.3" d="M1 0V140C1 151.046 9.95431 160 21 160H301" stroke="#33317e" stroke-width="2" />
          </svg>
          <svg v-show="from==='cs'" width="301" height="161" viewBox="0 0 301 161" fill="none"
               xmlns="http://www.w3.org/2000/svg">
            <path class="line cs-all" opacity="1" d="M1 0V140C1 151.046 9.95431 160 21 160H301" stroke="#33317e"
                  stroke-width="2" />
          </svg>
          <svg v-show="from==='zt'" width="301" height="161" viewBox="0 0 301 161" fill="none"
               xmlns="http://www.w3.org/2000/svg">
            <path class="line zt-all" opacity="1" d="M1 0V140C1 151.046 9.95431 160 21 160H301" stroke="#33317e"
                  stroke-width="2" />
          </svg>
        </div>
        <div class="svg svg-cs-ty">
          <svg width="201" height="161" viewBox="0 0 201 161" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path opacity="0.3" d="M200 0V140C200 151.046 191.046 160 180 160H0" stroke="#33317e" stroke-width="2" />
          </svg>
          <svg v-show="from==='cs'" width="201" height="161" viewBox="0 0 201 161" fill="none"
               xmlns="http://www.w3.org/2000/svg">
            <path class="line cs-all" opacity="1" d="M200 0V140C200 151.046 191.046 160 180 160H0" stroke="#33317e"
                  stroke-width="2" />
          </svg>
          <svg v-show="from==='ty'" width="201" height="161" viewBox="0 0 201 161" fill="none"
               xmlns="http://www.w3.org/2000/svg">
            <path class="line zt-all" opacity="1" d="M200 0V140C200 151.046 191.046 160 180 160H0" stroke="#33317e"
                  stroke-width="2" />
          </svg>
        </div>
        <div class="svg svg-cs-xt">
          <svg width="232" height="110" viewBox="0 0 232 110" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path opacity="0.3" d="M1 0V70C1 81.0457 9.9543 90 21 90H210.5C224 90 231 101 231 110" stroke="#33317E"
                  stroke-width="2" />
          </svg>
          <svg v-show="from==='cs'" width="232" height="110" viewBox="0 0 232 110" fill="none"
               xmlns="http://www.w3.org/2000/svg">
            <path class="line cs-all" opacity="1" d="M1 0V70C1 81.0457 9.9543 90 21 90H210.5C224 90 231 101 231 110"
                  stroke="#0c05ff" stroke-width="2" />
          </svg>
          <svg v-show="from==='xt'" width="232" height="110" viewBox="0 0 232 110" fill="none"
               xmlns="http://www.w3.org/2000/svg">
            <path class="line zt-all" opacity="1" d="M1 0V70C1 81.0457 9.9543 90 21 90H210.5C224 90 231 101 231 110"
                  stroke="#0c05ff" stroke-width="2" />
          </svg>

          <!-- <svg width="232" height="110" viewBox="0 0 232 110" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path class="line cs-all" opacity="0.1" fill-rule="evenodd" clip-rule="evenodd"
                  d="M2 0V70C2 80.4934 10.5066 89 21 89H191L211 89C222.598 89 232 98.402 232 110H230C230 99.5066 221.493 91 211 91L191 91H21C9.40202 91 0 81.598 0 70V0H2Z"
                  fill="#0c05ff" />
          </svg> -->
        </div>
        <div class="svg svg-zt-ty">
          <svg width="802" height="61" viewBox="0 0 802 61" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path opacity="0.3" d="M1 0V40C1 51.0457 9.95429 60 21 60H781C792.046 60 801 51.0457 801 40V0" stroke="#33317e"
                  stroke-width="2" />
          </svg>
          <svg v-show="from==='zt'" width="802" height="61" viewBox="0 0 802 61" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path class="line zt-all" opacity="1" d="M1 0V40C1 51.0457 9.95429 60 21 60H781C792.046 60 801 51.0457 801 40V0"
                  stroke="#33317e" stroke-width="2" />
          </svg>
          <svg v-show="from==='ty'" width="802" height="61" viewBox="0 0 802 61" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path class="line cs-all" opacity="1" d="M1 0V40C1 51.0457 9.95429 60 21 60H781C792.046 60 801 51.0457 801 40V0"
                  stroke="#33317e" stroke-width="2" />
          </svg>
        </div>
      </div>
      <div style="padding-bottom: 20px;">
        <el-button type="primary" class="btn-create" @click="$router.push({name:'scheduler-task-create',query:{from:from}})"
                   icon="el-icon-plus">创建调度任务</el-button>
      </div>
    </div>
  </el-card>
</template>

<script>
  import { random } from '@/module/util/util'
  export default {
    data () {
      return {
        random,
        from: 'zt',
        to: ''
      }
    }
  }
</script>

<style lang="scss" scoped>
.btn-create {
    width: 240px;
    font-size: 20px;
    font-weight: 600;
    background: linear-gradient(270deg, #33317e 0%, #5a58c5);
    border-radius: 4px;
    box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
    letter-spacing: 1px;
}
.draw {
    width: 1240px;
    margin: 0 auto;
    position: relative;
    height: 400px;
    .top-left {
        position: absolute;
        top: 0;
        left: 0;
        width: 540px;
        height: 140px;
        background: url(./images/bg_datacenter.png) no-repeat;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1100;
    }
    .top-right {
        position: absolute;
        top: 0;
        right: 0;
        width: 540px;
        height: 140px;
        background: url(./images/bg_datacenter2.png) no-repeat;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1100;
    }
    .idc {
        display: flex;
        flex-direction: column;
        justify-content: center;
        border-radius: 8px;
        box-shadow: 0px 0px 10px 0px rgba(86, 81, 254, 0.7);
        text-align: center;
        background-position: right center;
        z-index: 99;
        cursor: pointer;
        position: relative;
        &::before {
            position: absolute;
            content: ' ';
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 8px;
            z-index: 1;
        }
        .tips {
            position: absolute;
            right: 5px;
            top: 5px;
            color: #33317e;
            z-index: 100;
        }
        & > span {
            display: block;
            z-index: 100;
        }

        .text {
            top: 0;
            left: 0;
            width: 240px;
            height: 80px;
            z-index: 2;
            display: flex;
            flex-direction: column;
            justify-content: center;
            &.cs {
                background: url(./images/img_main_center1A.png);
            }
            &.zt {
                width: 340px;
                height: 100px;
                background: url(./images/img_main_center2A.png);
                background-size: 100%;
                background-position: left center;
            }
            &.xt {
                background: url(./images/img_main_center3A.png);
                background-size: 100%;
                background-position: left center;
            }
            &.ty {
                width: 400px;
                height: 80px;
                background: url(./images/img_main_center4A.png);
            }
        }

        .link {
            position: absolute;
            bottom: -24px;
            right: 0px;
            cursor: pointer;
            z-index: 9999;
        }

        .name {
            position: relative;
            z-index: 10;
            font-size: 30px;
            font-family: YouSheBiaoTiHei, YouSheBiaoTiHei-Regular;
            font-weight: 400;
            text-align: CENTER;
            color: #33317e;
            line-height: 30px;
            text-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.25);
        }
        .desc {
            position: relative;
            z-index: 10;
            font-size: 12px;
            color: #999999;
        }
        &.is-active {
            .tips {
                color: #ffffff;
            }
            &::before {
                position: absolute;
                content: ' ';
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                border-radius: 8px;
                background: linear-gradient(270deg, #33317e 0%, #5a58c5 100%) !important;
                z-index: 1;
            }
            .name,
            .desc {
                color: #ffffff !important;
            }
            .bg {
                display: block;
            }
        }
        .ripple {
            position: absolute;
            box-sizing: border-box;
            border: 10px solid #fff;
            border: none;
            background: rgba(51, 49, 126, 0.25);
            animation: ripple 2s linear infinite;
            animation-delay: calc(0.5s * var(--i));
        }
    }
    .idc + .idc {
        margin-left: 20px;
    }

    .center-center {
        position: absolute;
        top: 170px;
        left: 50%;
        transform: translateX(-50%);
        width: 800px;
        height: 200px;
        background: url(./images/bg_HPCcenter.png) no-repeat;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1100;
    }

    .svg {
        position: absolute;
        z-index: 1000;
        svg {
            position: absolute;
        }
        &.svg-cs-zt {
            left: 150px;
            top: 110px;
        }
        &.svg-cs-ty {
            right: 450px;
            top: 110px;
        }
        &.svg-cs-xt {
            left: 390px;
            top: 110px;
        }
        &.svg-zt-ty {
            left: 170px;
            top: 110px;
        }
        // &.ligth {
        //     svg {
        //         g {
        //             opacity: 1;
        //         }
        //         path {
        //             cursor: pointer;
        //             opacity: 1;
        //             stroke: #0c05ff;
        //         }
        //     }
        // }
    }
}

.info {
    cursor: pointer;
    .info-row {
        display: flex;
        justify-content: space-between;
        line-height: 20px;
    }
}
</style>
